package com.dingup.paike.bean.requestBean.pk;

import com.dingup.api.Util.DateUtil;
import com.dingup.paike.model.pk.PkLessonInfo;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by wancheng on 2018/9/26.
 */
public class PkLessonInfoSaveBatchRequestBean extends PkLessonInfoRequestBean{

    List<String> dayArray;
    String startTime;
    String finishTime;

    public List<PkLessonInfo> getPkLessonInfoArray() throws CloneNotSupportedException {
        PkLessonInfo pkLessonInfo = getPkLessonInfo();
        pkLessonInfo.setBeginTime(null);
        pkLessonInfo.setEndTime(null);
        List<PkLessonInfo> res = new ArrayList<>();
        startTime = StringUtils.isEmpty(startTime)?"00:00:00":startTime;
        finishTime = StringUtils.isEmpty(finishTime)?"00:00:00":finishTime;
        if (dayArray != null && dayArray.size() > 0){
            for (String day:dayArray){
                PkLessonInfo clone = pkLessonInfo.clone();
                clone.setBeginTime(DateUtil.str2Date(day+" "+startTime,"yyyy/MM/dd HH:mm"));
                clone.setEndTime(DateUtil.str2Date(day+" "+finishTime,"yyyy/MM/dd HH:mm"));
                res.add(clone);
            }
        }
        return res;
    }

    public List<String> getDayArray() {
        return dayArray;
    }

    public void setDayArray(List<String> dayArray) {
        this.dayArray = dayArray;
    }

    public String getStartTime() {
        return startTime;
    }

    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }

    public String getFinishTime() {
        return finishTime;
    }

    public void setFinishTime(String finishTime) {
        this.finishTime = finishTime;
    }
}
